home *** CD-ROM | disk | FTP | other *** search
- Path: hubcap.clemson.edu!hubcap!mjs
- From: mjs@hubcap.clemson.edu (M. J. Saltzman)
- Newsgroups: comp.lang.c
- Subject: Re: f;oating point precision
- Date: 6 Mar 96 15:50:09 GMT
- Organization: Clemson University
- Message-ID: <mjs.826127409@hubcap>
- References: <4hit8c$8lm@news.microsoft.com> <4hk7o5$gmk@crc-news.doc.ca>
- NNTP-Posting-Host: hubcap.clemson.edu
- X-Newsreader: NN version 6.5.0 #1
-
- don@mars.dgrc.doc.ca (Donald McLachlan) writes:
-
- >An even simpler example of the problem. The nice simple number .1 base10 cannot
- >be *exactly* represented as a binary number. My simple way of converting from
- >base10 decimals to binary is:
-
- >[algorithm for converting a decimal fraction to binary...]
-
- >For .1 base10, the process is:
-
- > math result
- > .1 * 2 = 0.2 .0
- > .2 * 2 = 0.4 .00 <----------------
- > .4 * 2 = 0.8 .000 |
- > .8 * 2 = 1.6 .0001 |
- > .6 * 2 = 1.2 .00011 |
- > .2 * 2 = 0.4 *** we have seen this case before, so we are in an infinite
- >loop (what is this called, and irrational number?) ***
-
- No, it's a rational number (the ratio of two integers, in this case
- 1/10 decimal or 1/1010 binary). Decimal or other radix expansion of a
- rational number always ends in an infinitely repeating finite-length
- sequence of digits (perhaps the infinitely repeating sequence of
- digits is '0', in which case we usually ignore it and say the
- expansion is finite).
-
- Irrational numbers are the ones that have infinite expansions that
- never repeat, like pi, e (the base of the natural log), sqrt(2.0),
- etc.
- --
- Matthew Saltzman
- Clemson University Math Sciences
- mjs@clemson.edu
-